﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace FatZombieAttack
{
    public class Map
    {
        private Texture2D Backround,grass;

        Rectangle UnaccesableAreaLeft = new Rectangle(-5, 0, 8, 750);
        Rectangle UnaccesableAreaRight = new Rectangle(1280, 0, 10, 750);
        Rectangle UnaccesableAreaTop = new Rectangle(0, -5, 1280, 8);
        Rectangle UnaccesableAreaDown = new Rectangle(0, 750, 1280, 10);
        Rectangle UnaccesableAreaGym = new Rectangle(1089, 120, 250, 165);
        Rectangle UnaccesableAreaMleft1 = new Rectangle(0, 0, 153, 384);
        Rectangle UnaccesableAreaMleft2 = new Rectangle(0, 525, 123, 384);
        Rectangle UnaccesableAreaPark = new Rectangle(200, 200, 315, 240);
        Rectangle UnaccesableAreaPark2 = new Rectangle(0, 0, 570, 154);
        Rectangle UnaccesableAreaPark3 = new Rectangle(705, 0, 580, 54);
        Rectangle UnaccesableAreaPark4 = new Rectangle(120, 645, 225, 105);
        Rectangle UnaccesableAreaHouse1 = new Rectangle(705, 225, 157, 124);
        Rectangle UnaccesableAreaHouse2 = new Rectangle(772, 490, 157, 124);
        Rectangle UnaccesableAreaHouse3 = new Rectangle(770, 695, 157, 124);
        Rectangle UnaccesableAreaHouse4 = new Rectangle(1090, 485, 200, 120);
        Rectangle UnaccesableAreaFence = new Rectangle(835, 450, 500, 40);
        Rectangle UnaccesableAreaHill = new Rectangle(835, 348, 500, 35);

        public Map() { }
        public void Initialize()
        {
           
        }
        public virtual void LoadContent(ContentManager Content)
        {
            Backround = Content.Load<Texture2D>("Sprites/PokemonMap");
            grass = Content.Load<Texture2D>("Sprites/Grass");
           
        }
        public virtual void Update(GameTime gameTime)
        {

        }
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(Backround, new Vector2(-50, -50), Color.White);
            
            //spriteBatch.Draw(grass,UnaccesableAreaLeft,Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaRight, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaTop, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaDown, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaGym, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaMleft1, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaMleft2, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaPark, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaPark2, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaPark3, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaPark4, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaHouse1, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaHouse2, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaHouse3, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaHouse4, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaFence, Color.Black);
            //spriteBatch.Draw(grass, UnaccesableAreaHill, Color.Black);
            
            
        }
        public bool CheckInside(float x, float y,Rectangle z)
        {
            if ((x < z.X || y < z.Y || x > (z.X + z.Width) || y > (z.Y + z.Height)) && (x + 60 < z.X || y + 60 < z.Y || x + 60 > (z.X + z.Width) || y + 60 > (z.Y + z.Height)) &&
                (x + 60 < z.X || y  < z.Y || x + 60 > (z.X + z.Width) || y  > (z.Y + z.Height)) && (x  < z.X || y + 60 < z.Y || x  > (z.X + z.Width) || y + 60 > (z.Y + z.Height)))
                return true;
            else
                return false;
        }
        public bool CheckInsideb(float x, float y, Rectangle z)
        {
            if ((x < z.X || y < z.Y || x > (z.X + z.Width) || y > (z.Y + z.Height)))
                return true;
            else
                return false;
        }
        public bool CheckInsidez(float x, float y, Rectangle z,int size)
        {
            float sized = 30;
            if (size == 0)
                sized = 30;
            else if (size == 1)
                sized = 60;
            else
                sized = 80;

            if ((x < z.X || y < z.Y || x > (z.X + z.Width) || y > (z.Y + z.Height)) && (x + sized < z.X || y + sized < z.Y || x + sized > (z.X + z.Width) || y + sized > (z.Y + z.Height)) &&
                (x + sized < z.X || y < z.Y || x + sized > (z.X + z.Width) || y > (z.Y + z.Height)) && (x < z.X || y + sized < z.Y || x > (z.X + z.Width) || y + sized > (z.Y + z.Height)))
                return true;
            else
                return false;
        }
        public bool CheckInsideAll(float x, float y)
        {
            bool u1 = CheckInside(x, y, UnaccesableAreaLeft);
            bool u2 = CheckInside(x, y, UnaccesableAreaRight);
            bool u3 = CheckInside(x, y, UnaccesableAreaTop);
            bool u4 = CheckInside(x, y, UnaccesableAreaDown);
            bool u5 = CheckInside(x, y, UnaccesableAreaGym);
            bool u6 = CheckInside(x, y, UnaccesableAreaMleft1);
            bool u7 = CheckInside(x, y, UnaccesableAreaMleft2);
            bool u8 = CheckInside(x, y, UnaccesableAreaPark);
            bool u9 = CheckInside(x, y, UnaccesableAreaPark2);
            bool u10 = CheckInside(x, y, UnaccesableAreaPark3);
            bool u11 = CheckInside(x, y, UnaccesableAreaPark4);
            bool u12 = CheckInside(x, y, UnaccesableAreaHouse1);
            bool u13 = CheckInside(x, y, UnaccesableAreaHouse2);
            bool u14 = CheckInside(x, y, UnaccesableAreaHouse3);
            bool u15 = CheckInside(x, y, UnaccesableAreaHouse4);
            bool u16 = CheckInside(x, y, UnaccesableAreaFence);
            bool u17 = CheckInside(x, y, UnaccesableAreaHill);

            return (u1 && u2 && u3 && u4 && u5 && u6 && u7 && u8 && u9 && u10 && u11 && u12 && u13 && u14 && u15 && u16 && u17);
        }
        public bool CheckInsideAllz(float x, float y,int size)
        {
            bool u5 = CheckInsidez(x, y, UnaccesableAreaGym, size);
            bool u6 = CheckInsidez(x, y, UnaccesableAreaMleft1, size);
            bool u7 = CheckInsidez(x, y, UnaccesableAreaMleft2, size);
            bool u8 = CheckInsidez(x, y, UnaccesableAreaPark, size);
            bool u9 = CheckInsidez(x, y, UnaccesableAreaPark2, size);
            bool u10 = CheckInsidez(x, y, UnaccesableAreaPark3, size);
            bool u11 = CheckInsidez(x, y, UnaccesableAreaPark4, size);
            bool u12 = CheckInsidez(x, y, UnaccesableAreaHouse1, size);
            bool u13 = CheckInsidez(x, y, UnaccesableAreaHouse2, size);
            bool u14 = CheckInsidez(x, y, UnaccesableAreaHouse3, size);
            bool u15 = CheckInsidez(x, y, UnaccesableAreaHouse4, size);
            bool u16 = CheckInsidez(x, y, UnaccesableAreaFence, size);
            //bool u17 = CheckInsidez(x, y, UnaccesableAreaHill, size);

            return (u5 && u6 && u7 && u8 && u9 && u10 && u11 && u12 && u13 && u14 && u15 && u16);
        }
        public bool CheckInsideAllb(float x, float y)
        {
            bool a = true;
            bool b = true;
            bool c = true;
            bool d = true;
            if (x > 1480)
                a = false;
            if (x < -200)
                b = false;
            if (y > 950)
                c = false;
            if (y < -200)
                d = false;

          
            bool u5 = CheckInsideb(x, y, UnaccesableAreaGym);
            bool u6 = CheckInsideb(x, y, UnaccesableAreaMleft1);
            bool u7 = CheckInsideb(x, y, UnaccesableAreaMleft2);
            bool u12 = CheckInsideb(x, y, UnaccesableAreaHouse1);
            bool u13 = CheckInsideb(x, y, UnaccesableAreaHouse2);
            bool u14 = CheckInsideb(x, y, UnaccesableAreaHouse3);
            bool u15 = CheckInsideb(x, y, UnaccesableAreaHouse4);
            bool u16 = CheckInsideb(x, y, UnaccesableAreaHill);


            return (u5 && u6 && u7 && u12 && u13 && u14 && u15 && u16 && a && b && c && d );
        }
    }
}
